<?php
require_once($_SERVER['DOCUMENT_ROOT'] . '/../start.php');//Подключаем файл инициализации

header('Content-Type: text/html; charset: utf-8');

$idRootFolder = intval($_POST['idFolder']);
$newFolderName = absolutelyEscapeString($_POST['newFolderName']);
if (!$newFolderName) $newFolderName = "Новая папка";

$idNewFolder = Main::createFolder($idRootFolder, $newFolderName);

$arrFolders = Main::getFolders();
$arrTree = Service_Array::convertLinealToTree($arrFolders);
$objMain = new View_Main();
$objMain->getTree($arrTree);

echo json_encode($objMain->str);
?>